<?php
if (!class_exists('EzpdoTemplate')) {
	require_once('lib/ezpdo/ezpdo_runtime.php');

	/**
	 *  Utility dao class for EZPDO ORM
	 *	@author Alecsandru Gabriel DINU
	 *  @since Jul 20n, 2008
	 */
	class EzpdoTemplate implements Singleton_Interface {
		private static $theInstance;
		private $epManager;

		/**
		 * Class constructor
		 * @access private
		 */
		private function __construct() {
			epLoadConfig('ezpdo-config.xml');
			$this->epManager = epManager::instance();
		}

		/**
		 * Class factory
		 * @access public
		 */
		public static function getInstance() {
			if (!self::$theInstance) {
				self::$theInstance = new EzpdoTemplate();
			}
			return self::$theInstance;
		}

		/**
		 * Get the persistence manager (a singleton)
		 * @access public
		 * @return epManager
		 */
		public function getEpManager() {
			return $this->epManager;
		}
		
		/**
		 * Override clone method to throw exception
		 * @access public
		 * @return void
		 * @throws Exception
		 */
		public function __clone() {
			throw new Exception('You cannot clone singleton object');
		}
		
	}
}
?>